<route>
    {
        meta: {
            layout: 'nepu',
            title:'流程审核'
        }
    }  
</route>
<template>
    <view>
        <a-table :columns="columns" :data-source="dataSource" :loading="loading" :pagination="pagination"
            @change="handleTableChange">
            <template #bodyCell="{ column, record, index }">
                <template v-if="column.dataIndex === 'status'">
                    <!--执行状态-->
                    <a-tag color="green" v-if="record.status">正常</a-tag>
                    <a-tag color="red" v-else>挂起</a-tag>

                </template>
                <template v-else-if="column.dataIndex === 'action'">
                    <a-button @click="$.emit('preview-flow',record)">预览</a-button>
                </template>
            </template>
        </a-table>
        <TaskDrawer></TaskDrawer>
        <DecisionDrawer></DecisionDrawer>
        <AntdShowModal ref="modal" title="中期报告" :width="860">
            <iframe id="iframe"
        name="iframe"
        height="500px"
        width="800px"
        scrolling="auto"
        frameborder="0" src="http://localhost:8080/office/preview/remote?url=http://150.158.135.236:8888/down/lBqplTn6jM7H.pdf"></iframe>
        </AntdShowModal>
    </view>
</template>
<script setup>
import DecisionDrawer from './components/DecisionDrawer.vue';
import TaskDrawer from './components/TaskDrawer.vue';
import useApp from '@/hooks'
const { $ } = useApp();
import { queryList } from '@/module/flow/api/task'
import { columns, defaultQueryParams } from './index';
const queryParams = ref($.freeStore(defaultQueryParams));
const dataSource = ref([]);
const total = ref(0);
const loading = ref(false);
const modal = ref(null)

const pagination = computed(() => ({
    total: total.value,
    current: queryParams.pageNum,
    pageSize: queryParams.pageSize,
}));
function handleTableChange(page, filters, sorted) {


    queryParams.value.pageSize = page.pageSize;
    queryParams.value.pageNum = page.current;

    // 状态
    var status = filters.status;
    console.log(status)
    if ($.isNotEmpty(status)) {
        queryParams.value.status = status[0];
    } else {
        queryParams.value.status = null
    }


    reqData();
}
// 请求数据
function reqData() {
    loading.value = true;
    queryList(queryParams.value).then(res => {
        console.log(res)
        loading.value = false;
        dataSource.value = res.content;
        total.value = res.totalElements;
        modal.value.openModal();
    })
}
reqData();
</script>